package infra.dao.project;

import java.io.File;
import models.Project;

public class ProjectDAO implements IProjectDAO {

    /* Constants */
    private final String PATH = File.separator + "Documents";
    
    /* Singleton Instance */
    private static ProjectDAO instance;
    
    private ProjectDAO() {
    }
    
    public static ProjectDAO getInstance() {
        if (instance == null) instance = new ProjectDAO();
        return instance;
    }
    
    @Override
    public void createProject(Project project) {
        File newFolder = new File(PATH + File.pathSeparator + project.getName());
    }

    @Override
    public File retrieveProjectByTitle(String title) {
        return new File(PATH + File.pathSeparator + title);
    }

    @Override
    public void updateProject(String oldSubPath, String newSubPath) {
        File oldFolder = new File(PATH + File.pathSeparator + oldSubPath);
        oldFolder.renameTo(new File(PATH + File.pathSeparator + newSubPath));
    }

    @Override
    public void deleteProject(String subPath) {
        File delFile = new File(PATH + File.pathSeparator + subPath);
        delFile.delete();
    }

    @Override
    public boolean folderExists(String subPath) {
        File checkFolder = new File(PATH + File.pathSeparator + subPath);
        return checkFolder.exists();
    }
    
}
